package com.inspectortime.domain.billing;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.inspectortime.common.PersistentEntityBase;
import com.inspectortime.domain.type.Address;
import com.inspectortime.domain.type.Name;
import com.inspectortime.timestamp.Timestamped;

@Entity
@Table(name = "PAYMENT")
public class Payment extends PersistentEntityBase implements Timestamped {
	
	private double amount;
	private ConfirmedStatus confirmedStatus = ConfirmedStatus.INITIATED;
	private Date createdTime;
	private String description;
	private Date lastModifiedTime;
	private List<PaymentLineItem> lineItems = new ArrayList<PaymentLineItem>();
	private Address payerAddress = new Address();	
	private String payerCompany;
	
	private String payerEmail;
	private Name payerName = new Name();
	private String payerPhone;
	private String paymentInvoiceNumber;
	private PaymentMethod paymentMethod;
	private PaymentSourceType paymentSourceType;
	private String responseCode;
	private String responseText;
	private String transactionId;

	private Date transactionTime;

	public Payment() {		
	}

	public Payment(PaymentSourceType type) {
		paymentSourceType = type;
	}

	public void addPaymentLineItem(String paymentSourceId) {
		PaymentLineItem line = new PaymentLineItem();
		line.setPaymentSourceId(paymentSourceId);
		line.setPayment(this);
		lineItems.add(line);
	}

	public double getAmount() {
		return amount;
	}

	public ConfirmedStatus getConfirmedStatus() {
		return confirmedStatus;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public String getDescription() {
		return description;
	}

	public Date getLastModifiedTime() {
		return lastModifiedTime;
	}

	@OneToMany(mappedBy = "payment", cascade = { CascadeType.ALL })
	public List<PaymentLineItem> getLineItems() {
		return lineItems;
	}

	public Address getPayerAddress() {
		return payerAddress;
	}

	public String getPayerCompany() {
		return payerCompany;
	}

	public String getPayerEmail() {
		return payerEmail;
	}

	public Name getPayerName() {
		return payerName;
	}

	public String getPayerPhone() {
		return payerPhone;
	}

	public String getPaymentInvoiceNumber() {
		return paymentInvoiceNumber;
	}

	public PaymentMethod getPaymentMethod() {
		return paymentMethod;
	}

	public PaymentSourceType getPaymentSourceType() {
		return paymentSourceType;
	}
	
	public String getResponseCode() {
		return responseCode;
	}

	public String getResponseText() {
		return responseText;
	}
	public String getTransactionId() {
		return transactionId;
	}
	
	public Date getTransactionTime() {
		return transactionTime;
	}
	
	public void setAmount(double amount) {
		this.amount = amount;
	}
	
	public void setConfirmedStatus(ConfirmedStatus confirmedStatus) {
		this.confirmedStatus = confirmedStatus;
	}
	
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setLastModifiedTime(Date lastModifiedTime) {
		this.lastModifiedTime = lastModifiedTime;
	}

	public void setLineItems(List<PaymentLineItem> lineItems) {
		this.lineItems = lineItems;
	}

	public void setPayerAddress(Address payerAddress) {
		this.payerAddress = payerAddress;
	}

	public void setPayerCompany(String payerCompany) {
		this.payerCompany = payerCompany;
	}

	public void setPayerEmail(String payerEmail) {
		this.payerEmail = payerEmail;
	}

	public void setPayerName(Name payerName) {
		this.payerName = payerName;
	}

	public void setPayerPhone(String payerPhone) {
		this.payerPhone = payerPhone;
	}

	public void setPaymentInvoiceNumber(String paymentInvoiceNumber) {
		this.paymentInvoiceNumber = paymentInvoiceNumber;
	}

	public void setPaymentMethod(PaymentMethod paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	public void setPaymentSourceType(PaymentSourceType paymentSourceType) {
		this.paymentSourceType = paymentSourceType;
	}

	public void setResponseCode(String responseCode) {
		this.responseCode = responseCode;
	}
	
	public void setResponseText(String responseText) {
		this.responseText = responseText;
	}

	public void setTransactionId(String transactionId) {
		this.transactionId = transactionId;
	}

	public void setTransactionTime(Date transactionTime) {
		this.transactionTime = transactionTime;
	}

}
